#include "tcpSocket.h"
#include "task.h"

int main()
{
    TcpSocket tp;
    tp.CreateSocket();
    std::string ip = "127.0.0.1";
    int port = 8080;
    if(tp.Connect(ip,port) == false)
    {
        std::cout << "Connect error" << std::endl;
        return 1;
    }
    while(1)
    {
        Task t;
        t.Init();
        int fd = tp.GetFD();
        char buf[128];
        memcpy(buf,&t,sizeof(t));
        int len = send(fd,buf,sizeof(t),0);
        std::cout << "client 已发送 " << len << std::endl;
        recv(fd,buf,4,0);
        int ret = 0;
        memcpy(&ret,buf,sizeof(int));
        std::cout << "Answer:" << ret << std::endl;
    }
    return 0;
}